{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['初始资金: 10000', '回测期间：20220101:20221231']\n",
      "初始资金: 10000\n",
      "回测期间：20220101:20221231\n"
     ]
    }
   ],
   "source": [
    "import datetime\n",
    "# 假设我们有以下变量\n",
    "start_cash = 10000\n",
    "start_date = datetime.datetime(2022, 1, 1)\n",
    "end_date = datetime.datetime(2022, 12, 31)\n",
    "\n",
    "# 创建一个空列表来存储打印内容\n",
    "print_list = []\n",
    "\n",
    "# 将print()内容格式化为字符串并添加到列表中\n",
    "print_list.append(f\"初始资金: {start_cash}\")\n",
    "print_list.append(f\"回测期间：{start_date.strftime('%Y%m%d')}:{end_date.strftime('%Y%m%d')}\")\n",
    "\n",
    "# 打印列表内容以验证\n",
    "print(print_list)\n",
    "for item in print_list:\n",
    "    print(item)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
